﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;

namespace Hangout.Client.Controls.User
{
    public partial class UserDetailsPanel : UserControl
    {
        public UserDetailsPanel()
        {
            InitializeComponent();
        }

        private AccountService.UserProfile profile;

        public AccountService.UserProfile Profile
        {
            get
            {
                return profile;

            }
            set
            {
                profile = value;
                if (Profile != null)
                {
                    LoadData();
                }
            }
        }

        private void LoadData()
        {
            try
            {
                if (Profile != null)
                {
                    LayoutRoot.Visibility = System.Windows.Visibility.Visible;
                    if (profile.Age != null)
                    {
                        AgeLBL.Text = profile.Age.ToString();
                    }
                    else
                    {
                        AgeSP.Visibility = System.Windows.Visibility.Collapsed;
                    }

                    if (profile.User.Status != null)
                    {
                        AboutMeLBL.Text = profile.User.Status;
                    }
                    else
                    {
                        AboutMeSP.Visibility = System.Windows.Visibility.Collapsed;
                    }

                    if (profile.Gender != null)
                    {
                        if ((bool)profile.Gender)
                        {
                            GenderText.Text = "Male";
                            GenderImage.Source = new BitmapImage(new Uri("Male Icon.png", UriKind.Relative));
                        }
                        else
                        {
                            GenderText.Text = "Female";
                            GenderImage.Source = new BitmapImage(new Uri("Female Icon.png", UriKind.Relative));
                        }

                    }
                    else
                    {
                        SexSP.Visibility = System.Windows.Visibility.Collapsed;
                    }

                    if (profile.RelationshipStatus != null)
                    {
                        if (profile.RelationshipStatus.ToLower() == "single" && (bool)profile.Gender)
                        {
                            RelationShipText.Text = "Single";
                            RelationShipImage.Source = new BitmapImage(new Uri("SingleMale.PNG", UriKind.Relative));
                        }

                        if (profile.RelationshipStatus.ToLower() == "single" && !(bool)profile.Gender)
                        {
                            RelationShipText.Text = "Single";
                            RelationShipImage.Source = new BitmapImage(new Uri("SingleFemale.PNG", UriKind.Relative));
                        }

                        if (profile.RelationshipStatus.ToLower() == "engaged")
                        {
                            RelationShipText.Text = "Engaged";
                            RelationShipImage.Source = new BitmapImage(new Uri("Engaged.PNG", UriKind.Relative));
                        }

                        if (profile.RelationshipStatus.ToLower() == "married")
                        {
                            RelationShipText.Text = "Married";
                            RelationShipImage.Source = new BitmapImage(new Uri("Married.PNG", UriKind.Relative));
                        }

                        if (profile.RelationshipStatus.ToLower() == "divorced")
                        {
                            RelationShipText.Text = "Divorced";
                            RelationShipImage.Source = new BitmapImage(new Uri("Divorced.PNG", UriKind.Relative));
                        }

                        if (profile.RelationshipStatus.ToLower() == "in a relationship")
                        {
                            RelationShipText.Text = "Relationship";
                            RelationShipImage.Source = new BitmapImage(new Uri("Relationship.PNG", UriKind.Relative));
                        }


                    }
                    else
                    {
                        RelationshipStatusSP.Visibility = System.Windows.Visibility.Collapsed;
                    }


                }
            }
            catch (Exception ex)
            {
                Core.Exceptions.ExceptionReporting.Report(ex);
                MessageBox.Show(ErrorText.GenericErrorText, ErrorText.GenericErrorCaption, MessageBoxButton.OK);
            }
        }

        private void ChangeImage(Image image, string path)
        {
            
        }
    }
}
